<?php

//PLUGIN type=action
//PLUGIN name=page.remove
//PLUGIN desc=Enables you to remove pages from your site
//PLUGIN group=native

    if (strlen($options['page']) > 1)
    {
        $del_path = _CONTENTPATH_ . $options['page'] . $postfix;
        if (file_exists($del_path))
        {
            // del her
            if (!unlinkRecursive($del_path, true))
            {
                $msg = 'Could not delete "' . $del_path . '"';
            }
            else
            {
                if (!empty($_REQUEST['nq']))
                {
                    header("Location:?q=" . $_REQUEST['nq']);
                    exit("failure");
                }
                header("Location:?q=command:cms;view:cms.dashboard;");
            }
        }
        else
        {
            // err
            $msg = "That page does not exist";
        }
        $smarty->assign("msg", $msg);
    }
    else
    {
        $smarty->assign("msg", 'Du prøver at slette rod siden.');
    }
?> 